package com.huabo.system.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.system.config.DateBaseConfig;
import com.huabo.system.mysql.entity.TblCirculationMySql;
import com.huabo.system.mysql.mapper.TblCirculationMySqlMapper;
import com.huabo.system.oracle.entity.TblCirculation;
import com.huabo.system.oracle.mapper.TblCirculationMapper;
import com.huabo.system.service.TblCirculationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TblCirculationServiceImpl implements TblCirculationService {

    @Resource
    private TblCirculationMapper tblCirculationMapper;

    @Resource
    private TblCirculationMySqlMapper tblCirculationMySqlMapper;

    @Override
    public Map<String, Object> findAll(BigDecimal staffid, TblCirculation tca, PageInfo<TblCirculation> pageInfo) {
        if (DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblCirculationMapper.findAll(pageInfo, staffid, tca));
            pageInfo.setTotalRecord(tblCirculationMapper.findAllCount(staffid, tca));
            resultMap.put("data", pageInfo);
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            return resultMap;
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblCirculationMySqlMapper.findAll(pageInfo, staffid, tca));
            pageInfo.setTotalRecord(tblCirculationMySqlMapper.findAllCount(staffid, tca));
            resultMap.put("data", pageInfo);
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            return resultMap;
        }
    }

    @Override
    public TblCirculation get(String cyid) {
        return tblCirculationMapper.selectByCyid(cyid);
    }

    @Override
    public TblCirculationMySql getMySql(String cyid) {
        return tblCirculationMySqlMapper.selectByCyid(cyid);
    }

    @Override
    public List<TblCirculation> findStaffid(String taskid) {
        return tblCirculationMapper.findStaffid(taskid);

    }

    @Override
    public List<TblCirculationMySql> findMyStaffid(String taskid) {
        return tblCirculationMySqlMapper.findStaffid(taskid);
    }

    @Override
    public List<TblCirculation> findAllStaffid(String taskid) {
        return tblCirculationMapper.findAllStaffid(taskid);
    }

    @Override
    public List<TblCirculationMySql> findAllMySqlStaffid(String taskid) {
        return tblCirculationMySqlMapper.findAllStaffid(taskid);
    }

    @Override
    public List<TblCirculation> findAllString(String s) {
        return tblCirculationMapper.findAllString(s);
    }

    @Override
    public List<TblCirculationMySql> findAllMySqlString(String s) {
        return tblCirculationMySqlMapper.findAllString(s);
    }

    @Override
    public TblCirculation saveTblCirculation(String type, String number, String name, String url,
                                             BigDecimal loginUser) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void delTblCirculation(TblCirculation c) {
        // TODO Auto-generated method stub

    }

    @Override
    public void update(TblCirculation c) {
        // TODO Auto-generated method stub

    }
}
